home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cenvid9.zip / PATHDEL.BAT < prev    next >
DOS Batch File  |  1994-03-04  |  1KB  |  49 lines

  1. @echo off
  2. REM *********************************************************
  3. REM *** PathDel.bat - remove a directory from the current ***
  4. REM *** ver.1         path if it's there                  ***
  5. REM *********************************************************
  6.  
  7. if "%1"=="" GOTO SHOW_HOW
  8. if not "%2"=="" GOTO SHOW_HOW
  9. cenvi %0.BAT %1
  10. GOTO FINI
  11.  
  12. :SHOW_HOW
  13. ECHO PathDel.bat - Delete a directory from the PATH if it's there
  14. ECHO USAGE: PathDel DirSpec
  15. GOTO FINI
  16.  
  17.  
  18. GOTO CENVI_EXIT
  19.  
  20. main(argc,argv)
  21. {
  22.    OldDir = argv[1]
  23.    if NULL == (Position = FindDirInPath(OldDir))
  24.       printf("The Directory \"%s\" is not in PATH.\n",OldDir)
  25.    else {
  26.       // copy from Path beyond this dir
  27.       strcpy(Position,Position+strlen(OldDir))
  28.       // if there is a semi-colon at this position, then copy from beyond that too
  29.       if (Position[0] == ';')
  30.          strcpy(Position,Position+1)
  31.    }
  32. }
  33.  
  34. FindDirInPath(Dir) // search through path for this Dir, return pointer if found
  35.                    // and return NULL if not found
  36. {
  37.    len = strlen(Dir)
  38.    p = PATH
  39.    do {
  40.       if ( 0 == strnicmp(p,Dir,len)  && (p[len]==0 || p[len]==';') )
  41.          return(p)
  42.       p = strchr(p,';')
  43.    } while( p++ != NULL )
  44.    return(NULL)
  45. }
  46.  
  47. :CENVI_EXIT
  48. :FINI
  49.